package WaiBao;

import java.util.Arrays;

public class BaiYaoWei {
    public static void main(String[] args) {
        String[] name = {"沈腾(班长)", "徐峥(副班长)", "小李(学习委员)", "马丽(组织委员)", "高博(团支书)", "黄渤", "徐朗", "杨根华", "王富贵", "杨云", "杨成光", "张英志",
                "倪大红", "杨祖梅", "余晖", "成龙", "曾强", "罗青", "文章", "周润发", "卢影", "王国纯", "李爱萍", "曾宇", "黄飞鸿", "张闫", "李艳萍", "杨志刚",
                "阿卡莎", "白耀玮(生活委员)"};//考生本人:白耀玮(生活委员)
        int[] age = {18, 22, 18, 21, 20, 21, 19, 21, 19, 19, 18, 21, 18, 20, 20, 19, 20, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20,22, 21, 20};//最后一位：考生年龄:20

        double[] cainiao1 = {77, 88, 81, 94, 88, 69, 78, 85, 60, 70, 91, 87, 75, 75, 62, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 61, 89, 96};
        double[] cainiao2 = {84, 84, 75, 64, 64, 85, 88, 90, 70, 94, 94, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 77, 69, 78, 64, 77, 95};
        double[] cainiao3 = {88, 69, 79, 91, 90, 79, 69, 83, 80, 60, 73, 87, 85, 85, 66, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 75, 95};


        double qian1;//代表每个学生的总分
        double qian2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            qian1 = cainiao1[i] + cainiao2[i] +cainiao3[i];
//            qian2 = (qian1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + qian1);
//            System.out.println(name[i] + "的平均分为:" +qian2);
//        }


        double fanyi1 = 0,fanyi2 = 0;
        double[] sougou = new double[30];
//        for (int i = 0; i < 30; i++) {
//            fanyi1=cainiao1[i] +cainiao2[i] +cainiao3[i];
//            fanyi2 = (fanyi1 * 1.0) / 3;
//            sougou[i] = fanyi2;
//        }
//
//        for (int i = 0; i < sougou.length - 1; i++) {
//            for (int j = 0; j < sougou.length - i - 1; j++) {
//                if (sougou[j] < sougou[j + 1]) {
//                    double temp = sougou[j];
//                    sougou[j] = sougou[j + 1];
//                    sougou[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(sougou[i]);
//        }


        double zhijia1 = 0, zhijia2 = 0, zhijia3 = 0;//计算每门课的平均分
        double yuying1 = 0,yuying2 = 0,yuying3 = 0;//计算每门课标准差
        double dingdi1 = 0, dingdi2 = 0,dingdi3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < cainiao1.length; i++) {
            sum2+=cainiao1[i];
        }
        zhijia1 = (sum2*1.0)/30;
        System.out.println("农业设施及环境调控的平均分为:"+zhijia1);
        double Sum = 0;
        for (int i = 0; i < cainiao2.length; i++) {
            Sum+=cainiao2[i];
        }
        zhijia2 = (Sum*1.0)/30;
        System.out.println("农业设施设计与制造的班级平均分为:"+zhijia2);
        double sum = 0;
        for (int i = 0; i <cainiao3.length; i++) {
            sum+=cainiao3[i];
        }
        zhijia3 = (sum*1.0)/30;
        System.out.println("园艺植物设施栽培学的班级平均分为:"+zhijia3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < cainiao1.length; i++) {
            c1+= (cainiao1[i] - zhijia1)*(cainiao1[i] - zhijia1);
        }
        yuying1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:"+yuying1);

        for (int i = 0; i <cainiao2.length; i++) {
            c2+= (cainiao2[i] - zhijia2)*(cainiao2[i] -zhijia2);
        }
        yuying2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与制造的班级标准差为:"+yuying2);

        for (int i = 0; i <cainiao3.length; i++) {
            c3+= (cainiao3[i] -zhijia3)*(cainiao3[i] - zhijia3);
        }
        yuying3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的班级标准差为:"+yuying3);
//////
        Arrays.sort(cainiao1);
        Arrays.sort(cainiao2);
        Arrays.sort(cainiao3);
        dingdi1 =( cainiao1[15]+cainiao1[14])*1.0/2;
        dingdi2 =( cainiao2[15]+cainiao2[14])*1.0/2;
        dingdi3 =( cainiao3[15]+cainiao3[14])*1.0/2;
        System.out.println("农业设施及环境调控的中位数为:"+dingdi1);
        System.out.println("农业设施设计与制造的中位数为:"+dingdi2);
        System.out.println("园艺植物设施栽培学的中位数为:"+dingdi3);



    }
}
